﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace System.Text
{
    public static class StringBuilderExtensions
    {

        public static StringBuilder AppendIf( this StringBuilder buffer, bool condition, string text )
        {
            if ( condition
                && buffer != null )
            {
                buffer.Append( text );
            }
            return buffer;
        }


        public static StringBuilder AppendLineIf( this StringBuilder buffer, bool condition )
        {
            return buffer.AppendLineIf( condition, null );
        }

        public static StringBuilder AppendLineIf( this StringBuilder buffer, bool condition, string text )
        {
            if ( condition
                && buffer != null )
            {
                buffer.AppendLine( text );
            }
            return buffer;
        }
    }
}
